/*
 *
 *
 */

#include "key_common.h"
#include "gkt_window_voice.h"

#if defined(GKT_CONFIG_VOICE_OUTPUT_ENABLE) && GKT_CONFIG_VOICE_OUTPUT_ENABLE

typedef struct {
	uint32_t ids[GKT_KEY_VOICE_MAX];
	uint32_t	valid_bits;
} key_voice_s;
static key_voice_s s_key_voice;

void gkt_key_voice_set_id(uint32_t type, uint32_t id)
{
	if (type < GKT_KEY_VOICE_MAX)
		s_key_voice.ids[type] = id;
}

void gkt_key_voice_mask(uint32_t masked_bits)
{
	s_key_voice.valid_bits = ~masked_bits;
}

void key_voice_play(uint32_t key_value, uint32_t type)
{
	if ((s_key_voice.ids[type] > 0)
		&& (s_key_voice.valid_bits & (1U << (key_value & 0x1f)))) 
	{
		gkt_window_voice_play(NULL, s_key_voice.ids[type], 
				GKT_WINDOW_VOICE_F_DETACHED, NULL);
	}
}

void key_voice_init(void)
{
	uint32_t i;

	for (i = 0; i < GKT_KEY_VOICE_MAX; i++)
		s_key_voice.ids[i] = 0;
	s_key_voice.valid_bits = ~0;
}

#endif

